﻿<Window x:Class="WpfPanelCanvas.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="700" Width="1200">
    <Window.Resources>
        <Style x:Key="Test" TargetType="{x:Type RadioButton}" BasedOn="{StaticResource {x:Type ToggleButton}}">
            <Setter Property="Height" Value="40" />
            <Setter Property="Width" Value="200" />
        </Style>
        <ControlTemplate x:Key="BlockWindowA">
            <Canvas Width="375" Height="270" Background="{x:Null}">
                <Rectangle Width="375" Height="270" Canvas.Left="0" Canvas.Top="0" Stretch="Fill" StrokeThickness="2" StrokeLineJoin="Round" Stroke="#FF000000" Visibility="Hidden" Fill="#FFE3E3E3"/>
                <Rectangle Width="207.742" Height="149.11" Canvas.Left="84.2661" Canvas.Top="35.7814" Stretch="Fill" StrokeThickness="2" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF"/>
                <Rectangle Width="56.0519" Height="125.074" Canvas.Left="96.1232" Canvas.Top="45.9692" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="1.83042,0.862351" EndPoint="3.28798,0.862351">
                            <LinearGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <SkewTransform CenterX="1.83042" CenterY="0.862351" AngleX="-34.6387" AngleY="0"/>
                                    <RotateTransform CenterX="1.83042" CenterY="0.862351" Angle="223.526"/>
                                </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <GradientStop Color="#FFC8D5ED" Offset="0"/>
                            <GradientStop Color="#FFD9E3F4" Offset="0.111478"/>
                            <GradientStop Color="#FFEAF1FC" Offset="0.250464"/>
                            <GradientStop Color="#FFCCE4F9" Offset="0.439703"/>
                            <GradientStop Color="#FFDDECFC" Offset="0.576432"/>
                            <GradientStop Color="#FFEEF4FF" Offset="0.721707"/>
                            <GradientStop Color="#FFDCEAFB" Offset="0.80572"/>
                            <GradientStop Color="#FFCBE0F8" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle Width="56.052" Height="125.074" Canvas.Left="160.376" Canvas.Top="45.8904" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="0.699733,0.862986" EndPoint="2.15729,0.862986">
                            <LinearGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <SkewTransform CenterX="0.699733" CenterY="0.862986" AngleX="-34.6387" AngleY="0"/>
                                    <RotateTransform CenterX="0.699733" CenterY="0.862986" Angle="223.526"/>
                                </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <GradientStop Color="#FFC8D5ED" Offset="0"/>
                            <GradientStop Color="#FFD9E3F4" Offset="0.111478"/>
                            <GradientStop Color="#FFEAF1FC" Offset="0.250464"/>
                            <GradientStop Color="#FFCCE4F9" Offset="0.439703"/>
                            <GradientStop Color="#FFDDECFC" Offset="0.576432"/>
                            <GradientStop Color="#FFEEF4FF" Offset="0.721707"/>
                            <GradientStop Color="#FFDCEAFB" Offset="0.80572"/>
                            <GradientStop Color="#FFCBE0F8" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle Width="56.0519" Height="125.074" Canvas.Left="225.318" Canvas.Top="46.2048" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="-0.425265,0.860452" EndPoint="1.0323,0.860452">
                            <LinearGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <SkewTransform CenterX="-0.425265" CenterY="0.860452" AngleX="-34.6388" AngleY="0"/>
                                    <RotateTransform CenterX="-0.425265" CenterY="0.860452" Angle="223.526"/>
                                </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <GradientStop Color="#FFC8D5ED" Offset="0"/>
                            <GradientStop Color="#FFD9E3F4" Offset="0.111478"/>
                            <GradientStop Color="#FFEAF1FC" Offset="0.250464"/>
                            <GradientStop Color="#FFCCE4F9" Offset="0.439703"/>
                            <GradientStop Color="#FFDDECFC" Offset="0.576432"/>
                            <GradientStop Color="#FFEEF4FF" Offset="0.721707"/>
                            <GradientStop Color="#FFDCEAFB" Offset="0.80572"/>
                            <GradientStop Color="#FFCBE0F8" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Path Width="220.345" Height="3.00049" Canvas.Left="78.1158" Canvas.Top="185.065" Stretch="Fill" StrokeThickness="3" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 79.6158,186.565L 296.961,186.566"/>
            </Canvas>
        </ControlTemplate>
        <ControlTemplate x:Key="BlockWindowC">
            <Canvas Width="540" Height="270">
                <Rectangle Width="540" Height="270" Canvas.Left="3.8147e-006" Canvas.Top="0.00012207" Stretch="Fill" StrokeThickness="0" StrokeLineJoin="Round" Stroke="#FF000000" Fill="{x:Null}"/>
                <Rectangle Width="486.715" Height="149.11" Canvas.Left="28.6526" Canvas.Top="35.7628" Stretch="Fill" StrokeThickness="2" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF"/>
                <Rectangle Width="56.8611" Height="125.074" Canvas.Left="444.017" Canvas.Top="45.8706" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="-0.862892,0.906273" EndPoint="1.90181,0.906273">
                            <LinearGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <SkewTransform CenterX="-0.862892" CenterY="0.906273" AngleX="-40.6012" AngleY="0"/>
                                    <RotateTransform CenterX="-0.862892" CenterY="0.906273" Angle="210.189"/>
                                </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <GradientStop Color="#FFC8D5ED" Offset="0"/>
                            <GradientStop Color="#FFD9E3F4" Offset="0.111478"/>
                            <GradientStop Color="#FFEAF1FC" Offset="0.250464"/>
                            <GradientStop Color="#FFCCE4F9" Offset="0.439703"/>
                            <GradientStop Color="#FFDDECFC" Offset="0.576432"/>
                            <GradientStop Color="#FFEEF4FF" Offset="0.721707"/>
                            <GradientStop Color="#FFDCEAFB" Offset="0.80572"/>
                            <GradientStop Color="#FFCBE0F8" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Path Width="503.05" Height="3.00098" Canvas.Left="20.7007" Canvas.Top="184.046" Stretch="Fill" StrokeThickness="3" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 22.2007,185.546L 522.251,185.547"/>
                <Rectangle Width="55.3176" Height="125.074" Canvas.Left="41.2559" Canvas.Top="46.7826" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="6.52751,0.898923" EndPoint="9.35112,0.898923">
                            <LinearGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <SkewTransform CenterX="6.52751" CenterY="0.898923" AngleX="-41.7874" AngleY="0"/>
                                    <RotateTransform CenterX="6.52751" CenterY="0.898923" Angle="209.496"/>
                                </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <GradientStop Color="#FFC8D5ED" Offset="0"/>
                            <GradientStop Color="#FFD9E3F4" Offset="0.111478"/>
                            <GradientStop Color="#FFEAF1FC" Offset="0.250464"/>
                            <GradientStop Color="#FFCCE4F9" Offset="0.439703"/>
                            <GradientStop Color="#FFDDECFC" Offset="0.576432"/>
                            <GradientStop Color="#FFEEF4FF" Offset="0.721707"/>
                            <GradientStop Color="#FFDCEAFB" Offset="0.80572"/>
                            <GradientStop Color="#FFCBE0F8" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle Width="116.225" Height="125.074" Canvas.Left="105.151" Canvas.Top="46.7032" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="2.52258,0.899563" EndPoint="4.33226,0.899563">
                            <LinearGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <SkewTransform CenterX="2.52258" CenterY="0.899563" AngleX="-4.10057" AngleY="0"/>
                                    <RotateTransform CenterX="2.52258" CenterY="0.899563" Angle="230.194"/>
                                </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <GradientStop Color="#FFC8D5ED" Offset="0"/>
                            <GradientStop Color="#FFD9E3F4" Offset="0.111478"/>
                            <GradientStop Color="#FFEAF1FC" Offset="0.250464"/>
                            <GradientStop Color="#FFCCE4F9" Offset="0.439703"/>
                            <GradientStop Color="#FFDDECFC" Offset="0.576432"/>
                            <GradientStop Color="#FFEEF4FF" Offset="0.721707"/>
                            <GradientStop Color="#FFDCEAFB" Offset="0.80572"/>
                            <GradientStop Color="#FFCBE0F8" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle Width="77.508" Height="125.074" Canvas.Left="232.026" Canvas.Top="46.6207" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="2.14081,0.900228" EndPoint="4.37176,0.900228">
                            <LinearGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <SkewTransform CenterX="2.14081" CenterY="0.900228" AngleX="-25.9418" AngleY="0"/>
                                    <RotateTransform CenterX="2.14081" CenterY="0.900228" Angle="218.547"/>
                                </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <GradientStop Color="#FFC8D5ED" Offset="0"/>
                            <GradientStop Color="#FFD9E3F4" Offset="0.111478"/>
                            <GradientStop Color="#FFEAF1FC" Offset="0.250464"/>
                            <GradientStop Color="#FFCCE4F9" Offset="0.439703"/>
                            <GradientStop Color="#FFDDECFC" Offset="0.576432"/>
                            <GradientStop Color="#FFEEF4FF" Offset="0.721707"/>
                            <GradientStop Color="#FFDCEAFB" Offset="0.80572"/>
                            <GradientStop Color="#FFCBE0F8" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle Width="114.567" Height="125.074" Canvas.Left="319.45" Canvas.Top="46.869" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="0.672421,0.898227" EndPoint="2.49298,0.898227">
                            <LinearGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <SkewTransform CenterX="0.672421" CenterY="0.898227" AngleX="-4.90217" AngleY="0"/>
                                    <RotateTransform CenterX="0.672421" CenterY="0.898227" Angle="229.785"/>
                                </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <GradientStop Color="#FFC8D5ED" Offset="0"/>
                            <GradientStop Color="#FFD9E3F4" Offset="0.111478"/>
                            <GradientStop Color="#FFEAF1FC" Offset="0.250464"/>
                            <GradientStop Color="#FFCCE4F9" Offset="0.439703"/>
                            <GradientStop Color="#FFDDECFC" Offset="0.576432"/>
                            <GradientStop Color="#FFEEF4FF" Offset="0.721707"/>
                            <GradientStop Color="#FFDCEAFB" Offset="0.80572"/>
                            <GradientStop Color="#FFCBE0F8" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
            </Canvas>
        </ControlTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition  Height="300" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <WrapPanel Grid.Row="0">
            <RadioButton Name="btnEllipse" Content="Ellipse" GroupName="paint" Style="{StaticResource Test}"  />
            <RadioButton Name="btnRectangle" Content="Rectangle" GroupName="paint" Style="{StaticResource Test}" />
            <RadioButton Name="btnBlock" GroupName="paint" Style="{StaticResource Test}" Click="btnBlock_Click" >
                <Viewbox>
                </Viewbox>
            </RadioButton>
        </WrapPanel>

        <Border BorderBrush="Black" BorderThickness="2"  Height="500" Width="1000" Grid.Row="1">
            <Canvas Name="kan" MouseMove="kan_MouseMove" MouseDown="kan_MouseDown" MouseUp="kan_MouseUp" Background="Transparent" MouseLeave="kan_MouseLeave" MouseEnter="kan_MouseEnter">
                <Ellipse Width="100" Height="100" Fill="Red"  />
                <Ellipse Canvas.Left="200" Canvas.Top="200" Width="150" Height="150" Fill="Green" />

                <Viewbox Height="100" Canvas.ZIndex="2" Canvas.Left="0" Canvas.Top="0">
                    <Button Template="{StaticResource BlockWindowA}" />
                </Viewbox>
            </Canvas>
        </Border>
    </Grid>
</Window>
